package com.cong.sort.select;

public class SelectSort {
    public static void main(String[] args) {
        int[] arr = {11,5,8,77,66,55,32};
        print(arr);
        sort(arr);
        System.out.println();
        print(arr);

    }

    public static void sort(int[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            int minPosition = i;
            for (int j = i+1; j < arr.length ; j++) {
                if (arr[minPosition]> arr[j])
                    minPosition=j;
            }
            swap(arr,minPosition,i);
        }
    }
    static void swap(int[] arr,int source,int target){
        int temp = arr[target];
        arr[target] = arr[source];
        arr[source] = temp;
    }
    static void print(int[] arr){
        for (int i : arr) {
            System.out.print(i+" ");
        }
    }
}
